<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>_${customer.customerName}_预包装拣货任务列表</title>
<script language="javascript" type="text/javascript" src="${ctx}/static/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
 
  //领取任务 
  function takeTask(taskId){
	  $.ajax({
			type:'post',
			url:'${ctx}/prepkgPick/ajaxTakePickTask',
			data:{
				taskId:taskId
			},
			dataType:'json',
			success:function(data) {
			    if(data==true){
			      $("#queryForm").submit();
			    }else{
			      alert("网络繁忙，请稍后重试...");
			    }
			},
			error:function() {
				alert("网络繁忙，请稍后重试...");
			}
	   });
  }
  
  

</script>
</head>

<body>

	<table id="contentTable" class="table table-striped table-bordered table-condensed">
	    <thead>
			<th style="vertical-align: middle; color: white; " colspan="13" bgcolor="#8EB4CB">我的拣货任务</th>
		</thead>
		<thead><tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>作业仓库</th>
			    <th>任务编号</th>
			    <th>创建时间</th>
			    <th>拣货执行人</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${myTaskList}" var="t" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>${t.customerCode}</td>
			   <td>${t.warehouseCode}</td>
			   <td>${t.taskCode}</td>
			   <td>${fn:substring(t.createTime,0,19)}</td>
			   <td>${t.workerUuid}</td>
			   <td>
			     <c:if test="${t.status eq 'token'}">已分配拣货任务</c:if>
			     <c:if test="${t.status eq 'doing'}">拣货中...</c:if>
			   </td>
			   <td>
			      <c:if test="${t.status eq 'token'}">
			         <a href="${ctx}/prepkgPick/toPickTaskPage/${t.id}" role="button"  class="btn btn-primary" >开始任务</a>
			      </c:if>
			      <c:if test="${t.status eq 'doing'}">
			         <a href="${ctx}/prepkgPick/toPickTaskPage/${t.id}" role="button"  class="btn btn-primary" >继续任务</a>
			      </c:if>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	
	<!-- 未分配的拣货任务 -->
	<table class="table table-striped table-bordered table-condensed" style="margin-top: 0px;">
		<thead>
			<th style="vertical-align: middle; color: white; " colspan="13" bgcolor="#8EB4CB">未分配的拣货任务</th>
		</thead>
		<tr >
		   <td colspan="13">
		     <form class="form-search" id="queryForm" method="post" action="${ctx}/prepkgPick/queryPickTaskList" style="margin-top: 10px;">
			 	
				
			  <label style="margin-left: 10px;">商家用户:</label>
			  <select class="input-medium required"  id="_customerCode" name="_customerCode"  value="${param._customerCode}" onchange="ajaxAreaGroup(this,'_warehouseCode');" >
				        <option value=""></option>
						<c:forEach items="${customerList}" var="customer">
							<option value="${customer.customerCode}"
							  <c:if test="${_customerCode eq customer.customerCode }">selected=selected</c:if>
							>${customer.customerName}</option>
						</c:forEach>
				</select> 
				
				<label style="margin-left: 10px;">作业仓库</label>
				 <select  name="_warehouseCode"  id="_warehouseCode" value="${param._warehouseCode}"  class="input-medium">
					<option value=""></option>
					<c:forEach items="${warehouseList}" var="w" >
					   <option value="${w.groupCode}" 
					   <c:if test="${_warehouseCode eq w.groupCode }">selected=selected</c:if>
					   >${w.groupName}</option>
				   </c:forEach>
				</select>
				
			    <button class="btn" type="submit" style="margin-left: 10px;">搜索</button>
		    </form>
		   </td>
		</tr>
		
		<thead><tr>
			    <th>序号</th>
			    <th>商家</th>
			    <th>作业仓库</th>
			    <th>任务编号</th>
			    <th>创建时间</th>
			    <th>拣货执行人</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${untakedPickTaskList}" var="t" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			    <td>${t.customerCode}</td>
			   <td>${t.warehouseCode}</td>
			   <td>${t.taskCode}</td>
			   <td>${fn:substring(t.createTime,0,19)}</td>
			   <td></td>
			   <td><font color=red>未分配拣货任务</font></td>
			   <td>
			      <input type="button" class="btn btn-primary" onclick="takeTask('${t.id}');" value="领取任务"/>
			   </td>
			</tr>
		</c:forEach>
		</tbody>
		
	</table>
	

</body>
</html>
